package com.leco.exam.webcommon.common;

import com.leco.exam.common.biz.errorcode.ErrorCode;

public class Response {

    private Response() {}

    public static <E> ResponseData<E> ok() {
        ResponseData<E> res = new ResponseData<E>();
        res.ok(null);
        return res;
    }

    public static <E> ResponseData<E> ok(E data) {
        ResponseData<E> res = new ResponseData<E>();
        res.ok(data);
        return res;
    }

    public static <E> ResponseData<E> ok(E data, String message) {
        ResponseData<E> res = new ResponseData<E>();
        res.ok(data, message);
        return res;
    }

    public static <E> ResponseData<E> fail(String message) {
        ResponseData<E> res = new ResponseData<E>();
        res.fail(message);
        return res;
    }

    public static <E> ResponseData<E> failByParams(String message) {
        ResponseData<E> res = new ResponseData<E>();
        res.fail(message);
        res.setCode(ErrorCode.BAD_REQUEST.getCode());
        return res;
    }

    public static <E> ResponseData<E> fail(String message, ErrorCode code) {
        ResponseData<E> res = new ResponseData<E>();
        res.fail(message, code);
        return res;
    }

    public static <E> ResponseData<E> fail(String message, int code) {
        ResponseData<E> res = new ResponseData<E>();
        res.fail(message, code);
        return res;
    }

    public static <E> ResponseData<E> fail(String message, int code, String requestId) {
        ResponseData<E> res = new ResponseData<E>();
        res.fail(message, code, requestId);
        return res;
    }

}
